﻿using Sidvall.Serialization;
using System;
using System.Globalization;
using System.Windows;

namespace Sidvall.UI.Wpf.Converters
{
    public class Int64ToVisibilityConverter : ValueToVisibilityConverterBase
    {
        #region Public Members

        #region VisibilityToValue

        protected override object VisibilityToValue(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is Visibility))
                return DependencyProperty.UnsetValue;
            switch ((Visibility)value)
            {
                case Visibility.Collapsed:
                case Visibility.Hidden:
                    if (!this.Not)
                        return null;
                    else
                        return parameter.ToNullableInt64();
                default:
                    if (!this.Not)
                        return parameter.ToNullableInt64();
                    else
                        return null;
            }
        }

        #endregion

        #endregion
    }
}
